#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	char alphabet[29] = {'a ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	int xq_digit = 1, xz_digit = 1, ch;
	while((ch = getchar())!='\n') {
		for (int i = 1; i < 27; i++) if (alphabet[i] == ch) xq_digit *= i;
	}
	while ((ch = getchar()) != '\n') {
		for (int i = 1; i < 27; i++) if (alphabet[i] == ch) xz_digit *= i;
	}
	xq_digit %= 47;xz_digit %= 47;
	if (xq_digit == xz_digit)printf("GO");
	else printf("STAY");
	return 0;
}